<!DOCTYPE html>
<html lang='en'>

<head>
    <meta charset='UTF-8'>
    <meta http-equiv='X-UA-Compatible' content='IE=edge'>
    <meta name='viewport' content='width=device-width, initial-scale=1.0'>
    <title>Document</title>
    <script src='https://cdn.staticfile.org/react/16.4.0/umd/react.development.js'></script>
    <script src='https://cdn.staticfile.org/react-dom/16.4.0/umd/react-dom.development.js'></script>
    <!-- 生产环境中不建议使用 -->
    <script src='https://cdn.staticfile.org/babel-standalone/6.26.0/babel.min.js'></script>
    <!-- PropTypes文件 -->
    <script src='https://unpkg.com/prop-types@15.6.2/prop-types.js'></script>
</head>

<body>
    <div id='app'>
    </div>
    <script type='text/babel'>
        class Demo extends React.Component{

            /*
                React.createRef调用后可以创建一个容器，该容器可以存储被ref所标识的节点，该容器是专人专用的。如果你给多个节点加同一个容器，那么会后者覆盖前者。
                缺点就是这种写法其实挺繁琐的，因为你每多一个ref需求，就要写一次createRef，挺麻烦的
            */
            input1 = React.createRef()

            render(){
                return (
                    <div>
                        <input type="text" ref={this.input1} onBlur={()=>{console.log(this.input1.current.value)}}/>    
                    </div>
                )
            }
        }

        ReactDOM.render(<Demo/>,document.getElementById('app'))
    </script>
</body>

</html>